/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Utility;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JLabel;

/**
 *
 * @author Thiago
 */
public class Relogio extends JLabel {
    private final DateFormat format;  
      
    public Relogio() {          
        format = new SimpleDateFormat("HH:mm");  
          
        Thread thread = new Thread(new Runnable() {  
            @Override  
            public void run() {  
                while (true) {  
                    doTime();  
                    try {  
                        Thread.sleep(59000L);  
                    } catch (InterruptedException ex) {  
                        Thread.currentThread().interrupt();  
                        break;  
                    }  
                }  
            }  
        }, "Hora: ");  
        thread.setDaemon(true);  
        thread.setPriority(Thread.MIN_PRIORITY + 1);  
        thread.start();  
    }  
      
    private void doTime() {  
        super.setText(format.format(new Date()));  
    }  
      
    @Override  
    public void setText(String text) {  
    }  
    
}
